package txt2bib.doctypes;

import java.util.ArrayList;
import java.util.Collection;

import txt2bib.tagtypes.TagType;

public abstract class DocType {
	private String ID;
	protected String type;
	private Collection<TagType> values;
	
	public DocType() {
		values = new ArrayList<TagType>();
		//type = this.getClass().getSimpleName();
		ID = null;
		init();
	}
	
	public void init()
	{	
		setType(this.getClass().getSimpleName());		
	}
	
	
	public String getType() {
		return type.toUpperCase();
	}
	
	public void setType(String type)
	{
		this.type = type.toUpperCase();
	}
	
	public String getStarter() {
		return "@" + type.toUpperCase();
	}

	public void setID(String iD) {
		ID = iD;
	}

	public String getID() {
		return ID;
	}	

	public Collection<TagType> getValues() {
		return values;
	}
	
	public void add(TagType tag)
	{
		tag.init();
		values.add(tag);
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
//		values = new ArrayList<TagType>();
//		type = this.getClass().getSimpleName();
		sb.append(type);
		
		for (TagType tag: values) 
			sb.append("\n\t")
				.append(tag);
		
		sb.append("\n");
		return sb.toString();
	}
}
